import logging
import os
from pathlib import Path

def setup_logger():
    """配置日志系统"""
    log_dir = Path.home() / ".pynavicat" / "logs"
    log_dir.mkdir(parents=True, exist_ok=True)

    log_file = log_dir / "pynavicat.log"

    logging.basicConfig(
        level=logging.INFO,
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        handlers=[
            logging.FileHandler(log_file),
            logging.StreamHandler()
        ]
    )

def get_logger(name):
    """获取指定名称的日志记录器"""
    return logging.getLogger(name)